<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>

<body>


<h1>修改昆虫信息</h1>

<form method="POST" th:action="@{/insect/update}">

    <input name="id" th:value="${insect.id}" type="hidden">
    <p>
        昆虫名：<input name="name" th:value="${insect.name}" type="text">
    </p>
    <p>
        昆虫寿命：<input name="life" th:value="${insect.life}" type="text">
    </p>
    <p>
        地域分布：<input name="area" th:value="${insect.area}" type="text">
    </p>
    <p>
        首次发现时间：<input name="discoveryTime" th:value="${#dates.format(insect.discoveryTime,'yyyy-MM-dd')}"
                            type="text"/>
    </p>
    <p>
        所属分类：
        <select name="cid">
            <option th:each="allType : ${allType}" th:selected="${insect.cid == allType.id}"
                    th:text="${allType.cname}" th:value="${allType.id}">
            </option>
        </select>
    </p>
    <p>
        <input type="submit" value="修改">
        <input onclick="history.back()" type="button" value="返回">
    </p>
</form>


<script src="/js/jquery.js"></script>
<script>
    // 将服务器端的值传递给 JavaScript 变量
    // var cidValue = parseInt("${insect.cid}");
    //
    // $(function () {
    //     console.log(cidValue);
    //     // 根据 cid 的值选中对应的下拉框
    //     $("select[name='cid'] option[value='" + cidValue + "']").prop("selected", true);
    // });
</script>

</body>

</html>